package com.vehicle_information_management_system.controller;

import com.vehicle_information_management_system.dto.*;
import com.vehicle_information_management_system.pojo.DepartmentInfo;
import com.vehicle_information_management_system.pojo.DriverInfo;
import com.vehicle_information_management_system.pojo.UserInfo;
import com.vehicle_information_management_system.pojo.VehicleInfo;
import com.vehicle_information_management_system.service.impl.*;
import com.vehicle_information_management_system.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/dataInfo")
@RestController
public class DataInfoController {
    @Autowired
    private VehicleInfoServiceImpl vehicleInfoService;
    @Autowired
    private DepartmentInfoServiceImpl departmentInfoService;
    @Autowired
    private DriverInfoServiceImpl driverInfoService;
    @Autowired
    private DrivingCostInfoServiceImpl drivingCostInfoService;
    @Autowired
    private TripInfoServiceImpl tripInfoService;

    @Autowired
    private UserInfoServiceImpl userInfoService;
    @RequestMapping("/getDataInfo")
    public Result<?> getDataInfo() {
        Map<String, Object> map = new HashMap<>();
        List<VehicleDto> vehicleInfoList = vehicleInfoService.getVehicleInfo();
        List<VehicleCount> vehicleCount=vehicleInfoService.getVehicleCountByManufacturer();
        List<DriverInfo> driverInfoList = driverInfoService.getDriverInfo();
        List<EmployeeCount> employeeCount = driverInfoService.getEmployeeCountByAge();
        List<DepartmentInfo> departmentInfoList = departmentInfoService.getDepartmentInfo();
        List<UserInfo> userInfoList = userInfoService.getUserInfo();
        List<TripCount> tripCountByDepartment = tripInfoService.getTripCountByDepartment();
        List<PeopleCount> peopleCountByDepartment = userInfoService.getPeopleCountByDepartment();
        Integer driverCount = driverInfoService.getDriverCount();
        Integer vehicleAllCount = vehicleInfoService.getVehicleCount();
        Integer tripCount = tripInfoService.getTripCountByMonth();
        Integer useCount=vehicleInfoService.getUseStatusVehicleCount();
        Double drivingCost = drivingCostInfoService.getDrivingCostInfoByMonth();
        map.put("vehicleInfoList", vehicleInfoList);
        map.put("driverInfoList", driverInfoList);
        map.put("departmentInfoList", departmentInfoList);
        map.put("vehicleCount",vehicleCount);
        map.put("employeeCount",employeeCount);
        map.put("driverCount",driverCount);
        map.put("vehicleAllCount",vehicleAllCount);
        map.put("tripCount",tripCount);
        map.put("drivingCost",drivingCost);
        map.put("userInfoList",userInfoList);
        map.put("useCount",useCount);
        map.put("tripCountByDepartment",tripCountByDepartment);
        map.put("peopleCountByDepartment",peopleCountByDepartment);
        return Result.success(map);
    }
}
